package com.lebang.service;

import com.alibaba.fastjson.JSON;
import com.lebang.domain.MemberDeviceInfo;
import com.lebang.example.MemberDeviceInfoExample;
import com.lebang.mapper.MemberDeviceInfoMapper;
import com.lebangweb.common.TextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @Author: xwj
 * @Date: 2020/06/16 13:44
 * @Version 1.0
 */
@Service
public class MemberDeviceInfoService extends BaseService<MemberDeviceInfo,Integer, MemberDeviceInfoExample>{

    @Autowired
    private MemberDeviceInfoMapper memberDeviceInfoMapper;


    @Async
    public void insertDeviceInfo(String params, String memberId) {
        if(TextUtil.isEmpty(params)||memberDeviceInfoMapper.countByMemberId(memberId)>0){
            return;
        }
        MemberDeviceInfo info = JSON.parseObject(params,MemberDeviceInfo.class);
        info.setMemberId(memberId);
        memberDeviceInfoMapper.insert(info);

    }
}
